// Two function need to be implemented , GameMapInfo_handler & GameMapInfo_handler_configMode
// used GM Variables
// ds_huntRuleCurrent : current hunt rule object .

function GameMapInfo_handler(){
    if(GM_safeVariables["ds_huntRuleCurrent"] != null && GM_safeVariables["ds_huntRuleCurrent"] != ''){
        var lis = $x("//div[@class='cz_info']/ul")[0].getElementsByTagName("li");
        if(lis[0].innerHTML.indexOf("狩猎次数") >= 0){ //the place has been visited,so re-select the target place
            log("选中的地点已经被狩猎过，重新跳转到地图页面选择其他地点...");
            clickLink("/GameMap");
            return;
        }
        var link = "";
        var links = $x("//div[@class='col1']")[0].getElementsByTagName('a');
        var currentHuntRule = GM_safeVariables["ds_huntRuleCurrent"];
        currentHuntRule = eval('('+currentHuntRule+')');
        var strHeroName = '';
        for(var m=0;m<currentHuntRule.heros.length;m++){
            var objHero = currentHuntRule.heros[m];
            strHeroName += objHero.name + ',';
        }
        log("正在按照规则的设定,为<strong>"+strHeroName+"</strong>选择规则预定的攻击方式.");
        for(var i=0;i<links.length;i++){
            if(currentHuntRule != null && currentHuntRule != '' && currentHuntRule.target == 'wild' && currentHuntRule.attackType == 'collect'){
                if(links[i].innerHTML == '采集'){
                    link = links[i].getAttribute('href');
                    break;
                }
            }else{
                if(links[i].innerHTML == '狩猎' || links[i].innerHTML == '出军' || links[i].innerHTML == '访问'){
                    link = links[i].getAttribute('href');
                    break;
                }
            }
        }
        if(link != "")
        clickLink(link);
        else{
            log("地图信息页面无法找到任何可操作的动作链接，跳转到首页...");
            clickLink("/mindex");
        }
    }else{
        log("您没有制定任何的狩猎规则,将自动跳转回首页...");
        clickLink('/mindex');
        return;
    }

}

function GameMapInfo_handler_configMode(){

}